<template>
  <view class="box">
    <view class="tou top fixed" :style="'padding-top:' + statusBarHeight1 + 'px'">
      <image
        @click="fanhui"
        class="image1"
        src="https://pic.bangbangtongcheng.com/static/fanhui_bai.png"
      />商家认证
    </view>
    <view class="tou top" :style="'padding-top:' + statusBarHeight1 + 'px'"></view>
    <form>
      <view class="cu-form-group">
        <view class="title"> <span style="color: red">*</span>公司名称 </view>
        <input type="text" maxlength="30" v-model="nameStore" placeholder="请填写公司名称" />
      </view>
      <radio-group class="block" @change="RadioChange">
        <view class="cu-form-group" style="justify-content: left">
          <view class="title"> <span style="color: red">*</span>商家类型 </view>
          <view
            style="width: 40%; display: flex; justify-content: space-evenly; align-items: center"
          >
            <radio
              class="green-1 margin-left-sm"
              :class="shopType == '1' ? 'checked' : ''"
              :checked="shopType == '1' ? true : false"
              value="1"
              :disabled="amend == 1 ? true : false"
              activeBackgroundColor="#39b54a"
            ></radio
            >店铺
            <radio
              class="green margin-left-sm"
              :class="shopType == '2' ? 'checked' : ''"
              :checked="shopType == '2' ? true : false"
              value="2"
              :disabled="amend == 1 ? true : false"
              activeBackgroundColor="#39b54a"
            ></radio
            >楼盘
          </view>
        </view>
      </radio-group>
      <!-- <radio-group class="block" @change="multipleChange">
        <view class="cu-form-group" style="justify-content: left;">
          <view class="title">
            <span style="color: red">*</span>连锁店
          </view>
          <view style="width:40%;display: flex;justify-content: space-evenly;align-items: center;">
            <radio class="green-1 margin-left-sm" :class="multipleShop == '1' ? 'checked' : ''"
              :checked="multipleShop == '1' ? true : false" value="1"></radio>是
            <radio class="green margin-left-sm" :class="multipleShop == '2' ? 'checked' : ''"
              :checked="multipleShop == '2' ? true : false" value="2"></radio>否
          </view>
        </view>
      </radio-group> -->
      <view class="cu-form-group" v-if="multipleShop == 1">
        <view class="title"> <span style="color: red">*</span>所属门店 </view>
        <input type="text" v-model="shopName" placeholder="请选择门店" disabled />
        <text @click="mendian" class="cuIcon-search text-orange" style="color: #64b6a8"></text>
      </view>
      <view class="cu-form-group">
        <view class="title"> <span style="color: red">*</span>办公区域 </view>
        <picker
          @change="dictionariesChange"
          :data-index="index"
          range-key="valueName"
          :range="dictionaries"
        >
          <view class="picker">{{ index > -1 ? dictionaries[index].valueName : '请选择' }}</view>
        </picker>
      </view>
      <view class="cu-form-group">
        <view class="title"> <span style="color: red">*</span>办公地址 </view>
        <!-- <input type="text" v-model="shopAddress" placeholder="请填写地址" /> -->
        <template v-if="shopAddress">
          <input v-model="shopAddress" />
        </template>
        <template v-else>
          <input v-model="shopAddress" @click="" disabled="true" placeholder="请选择定位获取地址" />
        </template>
        <text
          class="cuIcon-locationfill text-orange"
          style="color: #64b6a8;width: 80rpx;height: 80rpx;line-height: 80rpx;text-align: center;"
          @click="openMap"
        ></text>
      </view>
      <view class="cu-form-group">
        <view class="title"> <span style="color: red">*</span>门店联系电话 </view>
        <input type="number" v-model="shopPhone" maxlength="11" placeholder="请填写门店联系方式" />
      </view>
      <view class="cu-form-group">
        <view class="title"> <span style="color: red">*</span>法人姓名 </view>
        <input type="text" v-model="contacts" maxlength="30" placeholder="请填写法人姓名" />
      </view>
      <view class="cu-form-group">
        <view class="title"> <span style="color: red">*</span>联系人手机号 </view>
        <input
          type="text"
          v-model="contactsPhone"
          @click="tishi"
          placeholder="请填写联系方式"
          disabled
        />
      </view>
      <view class="cu-form-group">
        <view class="title"> <span style="color: red">*</span>门店介绍 </view>
      </view>
      <view class="jieshao">
        <view class="kuang">
          <view class="">
            <textarea
              v-model="shopIntroduce"
              maxlength="500"
              auto-height
              style="min-height: 100px"
              @input="sumfountnum"
              placeholder="请详细介绍门店"
            />
          </view>
          <!-- <p>{{ foutnum }}/999</p> -->
          <view class="biaoqian">{{ shopIntroduce.length }}/500</view>
        </view>
      </view>
      <view class="cu-form-group">
        <view class="title"> <span style="color: red">*</span>店铺头像 </view>
      </view>
      <view class="shangchuan">
        <view class="cu-form-group">
          <imageUploadCropper
            v-model="imgList"
            :lengthNum="1"
            selWidth="600rpx"
            selHeight="400rpx"
            :ratio="1.5"
          ></imageUploadCropper>
        </view>
        <view style="font-size: 24rpx; color: #999999; background-color: #fff; padding-left: 40rpx">
          上传要求清晰、健康、代表品牌形象
          <p style="margin-top: 10rpx">请勿使用二维码，最大5mb，200*200像素</p>
        </view>
      </view>
      <view class="cu-form-group">
        <view class="title"> <span style="color: red">*</span>营业执照 </view>
      </view>
      <view class="shangchuan">
        <view class="cu-form-group">
          <imageUpload v-model="imgList2" :lengthNum="1"></imageUpload>
        </view>
        <view style="font-size: 24rpx; color: #999999; background-color: #fff; padding-left: 40rpx"
          >上传要求信息清晰、最大2mb</view
        >
      </view>
      <view class="cu-form-group">
        <view class="title">
          <!-- <span style="color: red" v-if="shopType != 2">*</span> -->
          法人身份证（人像面）
        </view>
      </view>
      <view class="sfz">
        <view class="cu-form-group">
          <view class="grid col-4 grid-square flex-sub">
            <view
              class="bg-img id_card"
              v-for="(item, index) in imgList3"
              :key="index"
              @tap="ViewImage3"
              :data-url="imgList3[index]"
            >
              <image :src="imgUrl + imgList3[index]" mode="aspectFit" />
              <view
                class="cu-tag bg-red"
                @tap.stop="DelImg3"
                :data-index="index"
                v-if="status !== '0' || amend == 1"
              >
                <text class="cuIcon-close"></text>
              </view>
            </view>
            <view class="solids id_card" @tap="ChooseImages(3)" v-if="imgList3.length < 1">
              <img
                style="width: 100%; height: 100%"
                src="https://pic.bangbangtongcheng.com/static/sfz_f.png"
                alt
              />
            </view>
          </view>
        </view>
      </view>
      <view class="cu-form-group">
        <view class="title">
          <!-- <span style="color: red" v-if="shopType != 2">*</span> -->
          法人身份证（国徽面）
        </view>
      </view>
      <view class="sfz">
        <view class="cu-form-group">
          <view class="grid col-4 grid-square flex-sub">
            <view
              class="bg-img id_card"
              v-for="(item, index) in imgList4"
              :key="index"
              @tap="ViewImage4"
              :data-url="imgList4[index]"
            >
              <image :src="imgUrl + imgList4[index]" mode="aspectFit" />
              <view
                class="cu-tag bg-red"
                @tap.stop="DelImg4"
                :data-index="index"
                v-if="status !== '0' || amend == 1"
              >
                <text class="cuIcon-close"></text>
              </view>
            </view>
            <view class="solids id_card" @tap="ChooseImages(4)" v-if="imgList4.length < 1">
              <img
                style="width: 100%; height: 100%"
                src="https://pic.bangbangtongcheng.com/static/sfz_z.png"
                alt
              />
            </view>
          </view>
        </view>
      </view>
      <!-- 身份证 -->
      <view class="cu-form-group">
        <view class="title"> <span style="color: red">*</span>个人身份证（人像面） </view>
      </view>
      <view class="sfz">
        <view class="cu-form-group">
          <view class="grid col-4 grid-square flex-sub">
            <view
              class="bg-img id_card"
              v-for="(item, index) in imgList9"
              :key="index"
              @tap="ViewImage9"
              :data-url="imgList9[index]"
            >
              <image :src="imgUrl + imgList9[index]" mode="aspectFit" />
              <view
                class="cu-tag bg-red"
                @tap.stop="DelImg9"
                :data-index="index"
                v-if="status !== '0' || amend == 1"
              >
                <text class="cuIcon-close"></text>
              </view>
            </view>
            <view class="solids id_card" @tap="ChooseImages(9)" v-if="imgList9.length < 1">
              <img
                style="width: 100%; height: 100%"
                src="https://pic.bangbangtongcheng.com/static/sfzgr_f.png"
                alt
              />
            </view>
          </view>
        </view>
      </view>
      <view class="cu-form-group">
        <view class="title"> <span style="color: red">*</span>个人身份证（国徽面） </view>
      </view>
      <view class="sfz">
        <view class="cu-form-group">
          <view class="grid col-4 grid-square flex-sub">
            <view
              class="bg-img id_card"
              v-for="(item, index) in imgList10"
              :key="index"
              @tap="ViewImage10"
              :data-url="imgList10[index]"
            >
              <image :src="imgUrl + imgList10[index]" mode="aspectFit" />
              <view
                class="cu-tag bg-red"
                @tap.stop="DelImg10"
                :data-index="index"
                v-if="status !== '0' || amend == 1"
              >
                <text class="cuIcon-close"></text>
              </view>
            </view>
            <view class="solids id_card" @tap="ChooseImages(10)" v-if="imgList10.length < 1">
              <img
                style="width: 100%; height: 100%"
                src="https://pic.bangbangtongcheng.com/static/sfzgr_z.png"
                alt
              />
            </view>
          </view>
        </view>
      </view>
    </form>
    <!-- #ifdef MP-WEIXIN -->
    <cropper
      ref="croop"
      v-show="showCroop"
      :quality="1"
      :zzIndex="1000"
      :canScale="true"
      selWidth="624rpx"
      selHeight="416rpx"
      style="z-index: 1000"
      @upload="myUpload"
      class="userHeader"
    ></cropper>
    <!-- #endif -->
    <!-- #ifndef MP-WEIXIN-->
    <gmy-img-cropper
      ref="gmyImgCropper"
      quality="1"
      cropperType="ratio"
      :ratio="1.5"
      fileType="png"
      imgSrc=""
      style="z-index: 1000"
      @getImg="myUpload"
    >
    </gmy-img-cropper>
    <!-- #endif -->
    <view class="tijiao">
      <!-- <view class="but" @click="submit" v-if="status !== '0'">提交审核</view> -->
      <view class="but" v-if="status == 0">审核中，请耐心等待</view>
      <view class="but" v-if="status != 0" @click="submit">提交</view>
    </view>
    <uniBall></uniBall>
  </view>
</template>
<script>
  import permision from '@/js_sdk/wa-permission/permission.js'
  //#ifdef H5
  import wxshare from '../utils/index.js'
  //#endif
  //#ifdef MP-WEIXIN
  import cropper from '../components/lxiaoxiao-cropper/lxiaoxiao-cropper.vue'
  //#endif

  // #ifndef MP-WEIXIN
  import gmyImgCropper from '../components/gmy-img-cropper/gmy-img-cropper.vue'
  //#endif
  import imageUploadCropper from '../components/imageUploadCropper.vue'
  import imageUpload from '@/components/imageUpload.vue'
  import { mapGetters } from 'vuex'
  export default {
    components: {
      // #ifndef MP-WEIXIN
      gmyImgCropper,
      //#endif
      //#ifdef MP-WEIXIN
      cropper,
      //#endif
      imageUploadCropper,
      imageUpload,
    },
    data() {
      return {
        type: 1,
        ceng: false,
        video: '',
        xiaoq: '',
        id: '',
        shopType: '1',
        multipleShop: '2',
        nameStore: '',
        shopName: '',
        shopId: '',
        shopIntroduce: '',
        shopArea: '',
        shopAddress: '',
        longitude: '',
        latitude: '',
        shopPhone: '',
        contacts: '',
        contactsPhone: '',
        image: '',
        businessLicense: '',
        idCardIp: '',
        idCardDown: '',
        status: '2',
        imgList: [],
        imgList1: [],
        imgList2: [],
        imgList3: [],
        upload3:false,
        upload4:false,
        upload9:false,
        upload10:false,
        imgList4: [],
        // 个人身份证
        imgList9: [],
        imgList10: [],
        userInfo: uni.getStorageSync('Pduser'),
        index: -1,
        dictionaries: [],
        foutnum: 0,
        imgUrl: this.$imgSrc,
        amend: '',
        type: '',
        anti_shake: false,
        // 小程序裁剪是否展示
        showCroop: false,
      }
    },
    computed: {
      ...mapGetters(['statusBarHeight1', 'userinfo']),
    },
    onLoad(e) {
      console.log(this.userInfo)
      this.contactsPhone = this.userInfo.phone
      console.log(this.contactsPhone)
      if (uni.getStorageSync('locationState') == 1) {
        this.getLocation()
      }
      this.getDictionaries()
      this.init()
      /* #ifdef H5 */
      this.jinzhi()
      /* #endif */
      this.amend = e.amend
      this.type = e.type
    },
    methods: {
      init() {
        console.log(this.userInfo)
        let that = this
        that.imgList = []
        that.imgList2 = []
        that.imgList3 = []
        that.imgList4 = []
        ;(that.imgList9 = []),
          (that.imgList10 = []),
          this.$myRequest
            .get('/mob/user/getShopInfoDetailByCopy', {
              userId: that.userInfo.id,
            })
            .then((res) => {
              if (res.shopInfo) {
                that.id = res.shopInfo.id
                that.shopType = res.shopInfo.shopType
                that.shopIntroduce = res.shopInfo.shopIntroduce
                that.shopArea = res.shopInfo.shopArea
                //  if (res.shopInfo.mainStore && res.shopInfo.mainStore!='' && res.shopInfo.mainStore!=0) {
                // 	this.multipleShop='1'
                //        this.shopId=res.shopInfo.mainStore
                //        this.shopName=res.shopInfo.mainStoreShopName
                // }
                for (var i = 0; i < that.dictionaries.length; i++) {
                  if (that.dictionaries[i].valueName == res.shopInfo.shopArea) {
                    that.index = i
                  }
                }
                that.shopAddress = res.shopInfo.shopAddress
                that.nameStore = res.shopInfo.shopName
                that.longitude = res.shopInfo.longitude
                that.latitude = res.shopInfo.latitude
                that.shopPhone = res.shopInfo.shopPhone
                that.contacts = res.shopInfo.contacts
                that.contactsPhone = res.shopInfo.contactsPhone
                that.status = res.shopInfo.status
                console.log(that.status);
                that.jjPerson = res.shopInfo.jjPerson
                that.confirmDuty = res.shopInfo.confirmDuty
                that.imgList.push(res.shopInfo.image)
                that.imgList2.push(res.shopInfo.businessLicense)
                if (res.shopInfo.idCardUp){
                  that.imgList3.push(res.shopInfo.idCardUp)
                }
                if (res.shopInfo.idCardDown){
                	that.imgList4.push(res.shopInfo.idCardDown)
                }
                // yyykkk
                that.imgList9.push(res.shopInfo.cardUp)
                that.imgList10.push(res.shopInfo.cardDown)
              }
            })
      },
      RadioChange(e) {
        this.shopType = e.detail.value
      },
      tishi() {
        uni.showToast({
          title: '当前选择无法更改！',
          duration: 2000,
          icon: 'none',
        })
      },
      // 连锁店
      multipleChange(e) {
        this.multipleShop = e.detail.value
      },
      mendian() {
        uni.navigateTo({
          url: '/pages/my/shop',
        })
      },
      sumfountnum(e) {
        this.foutnum = e.detail.value.length
      },
      getDictionaries() {
        this.$myRequest
          .get('/mob/home/getDictionaries', {
            type: '7',
          })
          .then((res) => {
            console.log(res)
            this.dictionaries = res.list
          })
      },
      dictionariesChange(e) {
        console.log(e)
        this.index = e.detail.value
        this.shopArea = this.dictionaries[this.index].valueName
      },
      ViewImage(e) {
        uni.previewImage({
          urls: this.imgList,
          current: e.currentTarget.dataset.url,
        })
      },

      ViewImage2(e) {
        uni.previewImage({
          urls: this.imgList2,
          current: e.currentTarget.dataset.url,
        })
      },
      ViewImage3(e) {
        uni.previewImage({
          urls: this.imgList3,
          current: e.currentTarget.dataset.url,
        })
      },
      ViewImage4(e) {
        uni.previewImage({
          urls: this.imgList4,
          current: e.currentTarget.dataset.url,
        })
      },
      ViewImage9(e) {
        uni.previewImage({
          urls: this.imgList9,
          current: e.currentTarget.dataset.url,
        })
      },
      ViewImage10(e) {
        uni.previewImage({
          urls: this.imgList10,
          current: e.currentTarget.dataset.url,
        })
      },
      // DelImg(e) {
      //   uni.showModal({
      //     title: "",
      //     content: "确定要删除该图片？",
      //     cancelText: "取消",
      //     confirmText: "确定",
      //     success: (res) => {
      //       if (res.confirm) {
      //         this.imgList.splice(e.currentTarget.dataset.index, 1);
      //       }
      //     },
      //   });
      // },
      DelImg(e) {
        uni.showModal({
          title: '',
          content: '确定要删除头像？',
          cancelText: '取消',
          confirmText: '确定',
          success: (res) => {
            if (res.confirm) {
              this.imgList.splice(e.currentTarget.dataset.index, 1)
            }
          },
        })
      },
      DelImg2(e) {
        uni.showModal({
          title: '',
          content: '确定要删除营业执照？',
          cancelText: '取消',
          confirmText: '确定',
          success: (res) => {
            if (res.confirm) {
              this.imgList2.splice(e.currentTarget.dataset.index, 1)
            }
          },
        })
      },
      DelImg3(e) {
        uni.showModal({
          title: '',
          content: '确定要删除身份证人像面？',
          cancelText: '取消',
          confirmText: '确定',
          success: (res) => {
            if (res.confirm) {
              this.imgList3.splice(e.currentTarget.dataset.index, 1)
			   this.upload3 = false
            }
          },
        })
      },
      DelImg4(e) {
        uni.showModal({
          title: '',
          content: '确定要删除身份证国徽面？',
          cancelText: '取消',
          confirmText: '确定',
          success: (res) => {
            if (res.confirm) {
              this.imgList4.splice(e.currentTarget.dataset.index, 1)
			  this.upload4 = false
            }
          },
        })
      },
      DelImg9(e) {
        uni.showModal({
          title: '',
          content: '确定要删除个人身份证人像面？',
          cancelText: '取消',
          confirmText: '确定',
          success: (res) => {
            if (res.confirm) {
              this.imgList9.splice(e.currentTarget.dataset.index, 1)
			  this.upload9 = false
            }
          },
        })
      },
      DelImg10(e) {
        uni.showModal({
          title: '',
          content: '确定要删除个人身份证国徽面？',
          cancelText: '取消',
          confirmText: '确定',
          success: (res) => {
            if (res.confirm) {
              this.imgList10.splice(e.currentTarget.dataset.index, 1)
			  this.upload10 = false
            }
          },
        })
      },
      ChooseImage() {
        let _this = this
        _this.imgList = []
        uni.chooseImage({
          count: 1, //默认1
          sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
          // sourceType: ["album"], //从相册选择
          sourceType: ['camera', 'album'],
          success: (res) => {
            var imgFiles = res.tempFilePaths
            const tempFiles = res.tempFiles
            let length = '',resType;
            // #ifdef H5
            length = tempFiles[0].name.length
            resType = tempFiles[0].name.substring(length - 1, length)
            // #endif
            // #ifndef H5
            length = tempFiles[0].path.length
            resType = tempFiles[0].path.substring(length - 1, length)
            // #endif
            if (resType != 'g' && resType != 'G') {
              uni.showToast({
                title: '不支持当前文件格式',
                icon: 'none',
              })
              return
            }
            if (imgFiles.length > 1) {
              uni.showToast({
                title: '图片最多不能超过1张',
                duration: 2000,
                icon: 'none',
              })
              return
            }
            var uper
            imgFiles.forEach((el) => {
              uni.showToast({
                title: '正在上传请稍后',
                icon: 'none',
                duration: 2000,
              })
              uper = uni.uploadFile({
                // 需要上传的地址
                url: 'https://www.bangbangtongcheng.com/conven/ht/attach/qnUpload',
                // filePath 需要上传的文件
                filePath: el,
                name: 'file',
                success(res1) {
                  _this.imgList.push(JSON.parse(res1.data).data[0].url)
                },
              })
            })
            // onProgressUpdate 上传对象更新的方法
            uper.onProgressUpdate(function (res) {})
          },
          fail: (fail) => {
            if (this.$userActiveCancalAct.some(v => fail.errMsg.includes(v.failMsg))) {
              return false;
            }
            this.$SHOWMODAL_TO_SETTINGS();
          },
        })
      },
      jinzhi() {
        let _this = this
        let param = window.location.href.split('#')[0]
        uni.request({
          method: 'post',
          data: {
            url: param,
          },
          header: {
            'content-type': 'application/x-www-form-urlencoded',
          },
          url: 'https://www.bangbangtongcheng.com/conven//mob/login/getJsTicket.do',
          success(re) {
            _this.jinzhifx(re.data)
          },
        })
      },
      jinzhifx(data) {
        wxshare.config({
          debug: false, //是否打开调试
          appId: data.appId, // 公众号的唯一标识
          timestamp: data.timestamp, // 生成签名的时间戳
          nonceStr: data.nonce, // ，生成签名的随机串
          signature: data.signature, // 签名
          jsApiList: ['hideMenuItems'],
        })
        // 禁止分享
        wxshare.hideMenuItems({
          // 要隐藏的菜单项，只能隐藏“传播类”和“保护类”按钮，所有menu项见附录3
          menuList: [
            'menuItem:share:appMessage',
            'menuItem:share:timeline',
            'menuItem:share:timeline',
            'menuItem:share:qq',
            'menuItem:favorite',
            'menuItem:share:QZone',
            'menuItem:openWithSafari',
          ],
        })
      },
      // 裁剪
      otherChooseImage() {
        // #ifdef MP-WEIXIN
        this.showCroop = true
        this.$refs.croop.fSelect()
        //  #endif
        // #ifndef MP-WEIXIN
        this.$refs.gmyImgCropper.chooseImage()
        //  #endif
      },
      myUpload(rsp) {
        console.log(rsp, 11111111111)

        let filePath = ''
        // #ifndef MP-WEIXIN
        this.userInfo.image = rsp
        filePath = rsp
        // #endif
        // #ifdef MP-WEIXIN
        this.userInfo.image = rsp.path
        filePath = rsp.path
        this.showCroop = false
        //  #endif

        var _this = this
        this.imgList = []
        // console.log(filePath)
        var uper

        uni.showToast({
          title: '正在上传请稍后',
          icon: 'none',
          duration: 2000,
        })
        uper = uni.uploadFile({
          // 需要上传的地址
          url: 'https://www.bangbangtongcheng.com/conven/ht/attach/qnUpload',
          // filePath 需要上传的文件
          filePath: filePath,
          name: 'file',
          success(res1) {
            console.log(res1)
            if (res1.statusCode === 200) {
              _this.imgList.push(JSON.parse(res1.data).data[0].url)
            } else if (res1.statusCode === 413) {
              uni.showToast({
                title: '文件太大了。',
                icon: 'none',
                duration: 2000,
              })
            }
          },
        })

        // onProgressUpdate 上传对象更新的方法
        uper.onProgressUpdate(function (res) {})
      },
      async ChooseImages(type) {
		  let that = this
        if (type == 0) {
          that.otherChooseImage()
        } else if (type == 2) {
          that.ChooseImage2()
        } else if (type == 3) {
          if(this.upload3){
            return
          }
          that.ChooseImage3()
        } else if (type == 4) {
          if(this.upload4){
            return
          }
          that.ChooseImage4()
        } else if (type == 9) {
          if(this.upload9){
            return
          }
          that.ChooseImage9()
        } else if (type == 10) {
          if(this.upload10){
            return
          }
          that.ChooseImage10()
        }
      },
      ChooseImage2() {
        let _this = this
        _this.imgList2 = []
        uni.chooseImage({
          count: 1, //默认1
          sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
          // sourceType: ["album"], //从相册选择
          sourceType: ['camera', 'album'],
          success: (res) => {
            var imgFiles = res.tempFilePaths
            const tempFiles = res.tempFiles
            let length = '',resType;
            // #ifdef H5
            length = tempFiles[0].name.length
            resType = tempFiles[0].name.substring(length - 1, length)
            // #endif
            // #ifndef H5
            length = tempFiles[0].path.length
            resType = tempFiles[0].path.substring(length - 1, length)
            // #endif
            if (resType != 'g' && resType != 'G') {
              uni.showToast({
                title: '不支持当前文件格式',
                icon: 'none',
              })
              return
            }
            if (imgFiles.length > 1) {
              uni.showToast({
                title: '图片最多不能超过1张',
                duration: 2000,
                icon: 'none',
              })
              return
            }
            var uper
            imgFiles.forEach((el) => {
              uni.showToast({
                title: '正在上传请稍后',
                icon: 'none',
                duration: 2000,
              })
              uper = uni.uploadFile({
                // 需要上传的地址
                url: 'https://www.bangbangtongcheng.com/conven/ht/attach/qnUpload',
                // filePath 需要上传的文件
                filePath: el,
                name: 'file',
                success(res1) {
                  _this.imgList2.push(JSON.parse(res1.data).data[0].url)
                },
              })
            })
            // onProgressUpdate 上传对象更新的方法
            uper.onProgressUpdate(function (res) {})
          },
          fail: (fail) => {
            if (this.$userActiveCancalAct.some(v => fail.errMsg.includes(v.failMsg))) {
              return false;
            }
            this.$SHOWMODAL_TO_SETTINGS();
          },
        })
      },
      ChooseImage3() {
        let _this = this
        _this.imgList3 = []
        uni.chooseImage({
          count: 1, //默认1
          sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
          // sourceType: ["album"], //从相册选择
          sourceType: ['camera', 'album'],
          success: (res) => {
            _this.upload3 = true;
            var imgFiles = res.tempFilePaths
            const tempFiles = res.tempFiles
            let length = '',resType;
            // #ifdef H5
            length = tempFiles[0].name.length
            resType = tempFiles[0].name.substring(length - 1, length)
            // #endif
            // #ifndef H5
            length = tempFiles[0].path.length
            resType = tempFiles[0].path.substring(length - 1, length)
            // #endif
            if (resType != 'g' && resType != 'G') {
              uni.showToast({
                title: '不支持当前文件格式',
                icon: 'none',
              })
              return
            }
            if (imgFiles.length > 1) {
              uni.showToast({
                title: '图片最多不能超过1张',
                duration: 2000,
                icon: 'none',
              })
              return
            }
            var uper
            imgFiles.forEach((el) => {
              uni.showToast({
                title: '正在上传请稍后',
                icon: 'none',
                duration: 2000,
              })
              uper = uni.uploadFile({
                // 需要上传的地址
                url: 'https://www.bangbangtongcheng.com/conven/ht/attach/qnUpload',
                // filePath 需要上传的文件
                filePath: el,
                name: 'file',
                success(res1) {
                  _this.imgList3.push(JSON.parse(res1.data).data[0].url)
                },
              })
            })
            // onProgressUpdate 上传对象更新的方法
            uper.onProgressUpdate(function (res) {})
          },
          fail: (fail) => {
            if (this.$userActiveCancalAct.some(v => fail.errMsg.includes(v.failMsg))) {
              return false;
            }
            this.$SHOWMODAL_TO_SETTINGS();
          },
        })
      },
      ChooseImage4() {
        let _this = this
        _this.imgList4 = []
        uni.chooseImage({
          count: 1, //默认1
          sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
          // sourceType: ["album"], //从相册选择
          sourceType: ['camera', 'album'],
          success: (res) => {
            _this.upload4 = true;
            var imgFiles = res.tempFilePaths
            const tempFiles = res.tempFiles
            let length = '',resType;
            // #ifdef H5
            length = tempFiles[0].name.length
            resType = tempFiles[0].name.substring(length - 1, length)
            // #endif
            // #ifndef H5
            length = tempFiles[0].path.length
            resType = tempFiles[0].path.substring(length - 1, length)
            // #endif
            if (resType != 'g' && resType != 'G') {
              uni.showToast({
                title: '不支持当前文件格式',
                icon: 'none',
              })
              return
            }
            if (imgFiles.length > 1) {
              uni.showToast({
                title: '图片最多不能超过1张',
                duration: 2000,
                icon: 'none',
              })
              return
            }
            var uper
            imgFiles.forEach((el) => {
              uni.showToast({
                title: '正在上传请稍后',
                icon: 'none',
                duration: 2000,
              })
              uper = uni.uploadFile({
                // 需要上传的地址
                url: 'https://www.bangbangtongcheng.com/conven/ht/attach/qnUpload',
                // filePath 需要上传的文件
                filePath: el,
                name: 'file',
                success(res1) {
                  _this.imgList4.push(JSON.parse(res1.data).data[0].url)
                },
              })
            })
            // onProgressUpdate 上传对象更新的方法
            uper.onProgressUpdate(function (res) {})
          },
          fail: (fail) => {
            if (this.$userActiveCancalAct.some(v => fail.errMsg.includes(v.failMsg))) {
              return false;
            }
            this.$SHOWMODAL_TO_SETTINGS();
          },
        })
      },
      ChooseImage9() {
        let _this = this
        _this.imgList9 = []
        uni.chooseImage({
          count: 1, //默认1
          sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
          // sourceType: ["album"], //从相册选择
          sourceType: ['camera', 'album'],
          success: (res) => {
            _this.upload9 = true;
            var imgFiles = res.tempFilePaths
            const tempFiles = res.tempFiles
            let length = '',resType;
            // #ifdef H5
            length = tempFiles[0].name.length
            resType = tempFiles[0].name.substring(length - 1, length)
            // #endif
            // #ifndef H5
            length = tempFiles[0].path.length
            resType = tempFiles[0].path.substring(length - 1, length)
            // #endif
            if (resType != 'g' && resType != 'G') {
              uni.showToast({
                title: '不支持当前文件格式',
                icon: 'none',
              })
              return
            }
            if (imgFiles.length > 1) {
              uni.showToast({
                title: '图片最多不能超过1张',
                duration: 2000,
                icon: 'none',
              })
              return
            }
            var uper
            imgFiles.forEach((el) => {
              uni.showToast({
                title: '正在上传请稍后',
                icon: 'none',
                duration: 2000,
              })
              uper = uni.uploadFile({
                // 需要上传的地址
                url: 'https://www.bangbangtongcheng.com/conven/ht/attach/qnUpload',
                // filePath 需要上传的文件
                filePath: el,
                name: 'file',
                success(res1) {
                  _this.imgList9.push(JSON.parse(res1.data).data[0].url)
                },
              })
            })
            // onProgressUpdate 上传对象更新的方法
            uper.onProgressUpdate(function (res) {})
          },
          fail: (fail) => {
            if (this.$userActiveCancalAct.some(v => fail.errMsg.includes(v.failMsg))) {
              return false;
            }
            this.$SHOWMODAL_TO_SETTINGS();
          },
        })
      },
      ChooseImage10() {
        let _this = this
        _this.imgList10 = []
        uni.chooseImage({
          count: 1, //默认1
          sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
          // sourceType: ["album"], //从相册选择
          sourceType: ['camera', 'album'],
          success: (res) => {
            _this.upload10 = true;
            var imgFiles = res.tempFilePaths
            const tempFiles = res.tempFiles
            let length = '',resType;
            // #ifdef H5
            length = tempFiles[0].name.length
            resType = tempFiles[0].name.substring(length - 1, length)
            // #endif
            // #ifndef H5
            length = tempFiles[0].path.length
            resType = tempFiles[0].path.substring(length - 1, length)
            // #endif
            if (resType != 'g' && resType != 'G') {
              uni.showToast({
                title: '不支持当前文件格式',
                icon: 'none',
              })
              return
            }
            if (imgFiles.length > 1) {
              uni.showToast({
                title: '图片最多不能超过1张',
                duration: 2000,
                icon: 'none',
              })
              return
            }
            var uper
            imgFiles.forEach((el) => {
              uni.showToast({
                title: '正在上传请稍后',
                icon: 'none',
                duration: 2000,
              })
              uper = uni.uploadFile({
                // 需要上传的地址
                url: 'https://www.bangbangtongcheng.com/conven/ht/attach/qnUpload',
                // filePath 需要上传的文件
                filePath: el,
                name: 'file',
                success(res1) {
                  _this.imgList10.push(JSON.parse(res1.data).data[0].url)
                },
              })
            })
            // onProgressUpdate 上传对象更新的方法
            uper.onProgressUpdate(function (res) {})
          },
          fail: (fail) => {
            if (this.$userActiveCancalAct.some(v => fail.errMsg.includes(v.failMsg))) {
              return false;
            }
            this.$SHOWMODAL_TO_SETTINGS();
          },
        })
      },
      fanhui() {
        uni.navigateBack({
          delta: 1,
        })
      },
      async getLocation() {
        this.getLocation1()
      },
      getLocation1() {
        let _this = this
        uni.getLocation({
          type: 'gcj02',
          highAccuracyExpireTime: '3000',
          success(res) {
            console.log(res)
            _this.latitude = res.latitude
            _this.longitude = res.longitude
            // _this.openMap();
          },
          fail:(res) => {
            console.log(res, '经纬度没有授权');
            this.$SHOWMODAL_TO_SETTINGS();
            uni.setStorageSync('locationState', 0)
            if (uni.getStorageSync('locationState') == 0) {
              // uni.showModal({
              //   title: '提示',
              //   content: '您已关闭位置权限或获取位置信息失败',
              //   success: function (res) {
              //     if (res.confirm) {
              //       // plus.runtime.openURL("app-settings:");
              //       if (plus.os.name === 'iOS') {
              //         plus.runtime.openURL('app-settings://')
              //       } else {
              //         var Intent = plus.android.importClass('android.content.Intent')
              //         var Settings = plus.android.importClass('android.provider.Settings')
              //         var Uri = plus.android.importClass('android.net.Uri')
              //         var mainActivity = plus.android.runtimeMainActivity()
              //         var intent = new Intent()
              //         intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
              //         var uri = Uri.fromParts('package', mainActivity.getPackageName(), null)
              //         intent.setData(uri)
              //         mainActivity.startActivity(intent)
              //       }
              //     } else if (res.cancel) {
              //       console.log('用户点击取消')
              //     }
              //   },
              // })
              return false
            }
          },
        })
      },
      openMap() {
        let that = this
        if (that.latitude == '' || that.longitude == undefined) {
          this.getLocation()
          return
        } else {
          uni.chooseLocation({
            latitude: that.latitude,
            longitude: that.longitude,
            success: function (res) {
              console.log(res)
              // that.location = res.name;
              that.shopAddress = res.address
              that.latitude = res.latitude
              that.longitude = res.longitude
            },
          })
        }
      },
      // 提交
      submit() {
        let that = this
        if (this.anti_shake) {
          return false
        }
        let data = {}
        var status = true
        if (!that.userInfo.id) {
          uni.showToast({
            title: '请先登录',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        if (!that.nameStore) {
          uni.showToast({
            title: '请填写门店名称',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        if (that.nameStore.length > 30) {
          uni.showToast({
            title: '门店名称上限为30个字符',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        //   if (that.multipleShop=='1') {
        //     if (that.shopId=='') {
        //           uni.showToast({
        //             title: "请选择连锁店",
        //             icon: "none",
        //             mask: true,
        //           });
        //           status = false;
        //           return false;
        //     }
        // }
        if (!that.shopType) {
          uni.showToast({
            title: '请选择门店类型',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        if (!that.shopIntroduce) {
          uni.showToast({
            title: '请填写门店介绍',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        if (!that.shopArea) {
          uni.showToast({
            title: '请选择门店区域',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        if (!that.shopAddress) {
          uni.showToast({
            title: '请选择门店地址',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        if (!that.longitude) {
          uni.showToast({
            title: '请选择门店地址',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        if (!that.shopPhone) {
          uni.showToast({
            title: '请填写门店联系方式',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        if (!that.contacts) {
          uni.showToast({
            title: '请填写门店联系人',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        if (that.imgList.length <= 0) {
          uni.showToast({
            title: '请上传头像',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        if (that.imgList2.length <= 0) {
          uni.showToast({
            title: '请上传营业执照',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        // if (that.imgList3.length <= 0 && this.shopType != 2) {
        //   uni.showToast({
        //     title: "请上传法人身份证人像面",
        //     icon: "none",
        //     mask: true,
        //   });
        //   status = false;
        //   return false;
        // }
        // if (that.imgList4.length <= 0 && this.shopType != 2) {
        //   uni.showToast({
        //     title: "请上传法人身份证国徽面",
        //     icon: "none",
        //     mask: true,
        //   });
        //   status = false;
        //   return false;
        // }
        // yyykkk
        if (that.imgList9.length <= 0) {
          uni.showToast({
            title: '请上传个人身份证人像面',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        if (that.imgList10.length <= 0) {
          uni.showToast({
            title: '请上传个人身份证国徽面',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        data.userId = that.userInfo.id
        data.id = that.id
        data.shopType = that.shopType
        data.shopName = that.nameStore
        // data.mainStore=that.multipleShop=='1'?that.shopId:'0'
        data.shopIntroduce = that.shopIntroduce
        data.shopArea = that.shopArea
        data.shopAddress = that.shopAddress
        data.longitude = that.longitude
        data.latitude = that.latitude
        data.shopPhone = that.shopPhone
        data.contacts = that.contacts
        data.contactsPhone = that.contactsPhone
        data.image = that.imgList[0]
        data.businessLicense = that.imgList2[0]
		if (that.imgList3.length>0){
			data.idCardUp = that.imgList3[0]
		}
        if (that.imgList4.length>0){
        	 data.idCardDown = that.imgList4[0]
        }
        // yyykkk
        data.cardUp = that.imgList9[0]
        data.cardDown = that.imgList10[0]
        data.status = that.status == 2 ? '0' : this.status
        if (status) {
          this.anti_shake = true
          this.$myRequest.post('/mob/user/saveShopInfo', data).then((res) => {
            if (res.success && res.code == 200) {
              uni.showToast({
                title: res.msg,
                icon: 'none',
                mask: true,
              })
              setTimeout(() => {
                this.anti_shake = false
              }, 500)
              if (that.type) {
                setTimeout(() => {
                  uni.switchTab({
                    url: '/pages/index/index',
                  })
                }, 500)
                return
              }
              that.init()
            } else {
              uni.showToast({
                title: res.msg,
                icon: 'none',
                mask: true,
              })
              that.init()
            }
          })
        }
      },
    },
  }
</script>
<style lang="less" scoped>
  .tou {
    position: relative;
    width: 100%;
    text-align: center;
    line-height: 88rpx;
    font-size: 36rpx;
    color: #fff;
    background-color: #64b6a8;
    .image1 {
      position: absolute;
      width: 32rpx;
      height: 32rpx;
      // top: 116rpx;
      left: 30rpx;
    }
  }
</style>
<style lang="less" scoped>
  .box {
    padding-bottom: 140rpx;
    min-height: 100vh;
    background-color: #fff;
  }
  .scroll-view {
    /* #ifdef MP  */
    height: calc(100vh - var(--status-bar-height) - 88rpx - 5px - 22px - 196rpx);
    /* #endif */
    /* #ifdef H5 || APP-PULS */
    height: calc(100vh - var(--status-bar-height) - 88rpx - 5px - 196rpx);
    /* #endif */
    /* #ifdef APP */
    height: calc(100vh - var(--status-bar-height) - 88rpx - 5px - 196rpx);
    /* #endif */
  }
  .tijiao {
    position: fixed;
    width: 100%;
    bottom: 0rpx;
    padding-bottom: 40rpx;
    background-color: #fff;
    z-index: 99;

    checkbox {
      vertical-align: top;
      margin-right: 6rpx;
      margin-left: 40rpx;
    }

    span {
      font-size: 26rpx;
    }

    .but {
      width: 670rpx;
      height: 80rpx;
      background: #64b6a8;
      border-radius: 50rpx;
      font-size: 34rpx;
      text-align: center;
      line-height: 80rpx;
      color: #fff;
      margin-top: 24rpx;
      margin-left: 40rpx;
    }
  }

  .jieshao {
    background-color: #fff;

    .kuang {
      position: relative;
      width: 670rpx;
      min-height: 80rpx;
      margin-left: 40rpx;
      // padding-bottom: 40rpx;
      background-color: #fff;
      border: 1px solid #c9c9c9;
      .biaoqian {
        height: 40rpx;
        display: flex;
        justify-content: flex-end;
        align-items: center;
        margin-right: 10rpx;
        color: #64b6a8;
      }
      textarea {
        width: 620rpx;
        margin-left: 24rpx;
        margin-top: 14rpx;
        line-height: 50rpx;
        letter-spacing: 2rpx;
      }

      p {
        position: absolute;
        bottom: 20rpx;
        right: 20rpx;
        color: #999999;
      }
    }
  }

  .cu-form-group uni-picker .picker {
    text-align: left;
  }

  .cu-form-group .title {
    font-weight: 600;
    font-size: 34rpx;
  }

  .grid.col-4.grid-square > uni-view {
    width: 212rpx;
    height: 212rpx;
  }

  /* .sfz {
  .grid.col-4.grid-square > uni-view {
    width: 670rpx;
    height: 360rpx;
    border-radius: 10rpx;
  }
} */
  .sfz .id_card {
    width: 670rpx !important;
    height: 360rpx !important;
    border-radius: 10rpx !important;
    padding-bottom: 0px !important;
  }

  .grid.col-4.grid-square > uni-view:nth-child(3n) {
    margin-right: 0;
  }
  .fixed {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 40;
  }
</style>
